package com.bkhc.product.api;

import com.bkhc.common.annotation.ApiOperation;
import com.bkhc.common.annotation.ApiPackage;
import com.bkhc.common.annotation.AuditLog;
import com.bkhc.common.enu.OperationEnum;
import com.bkhc.common.util.response.ResultJson;
import com.bkhc.product.entity.*;
import com.bkhc.product.service.BrandProductService;
import com.bkhc.product.service.BrandService;
import com.bkhc.product.service.PriceService;
import com.bkhc.product.vo.*;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/brandProduct")
@Api("品牌管理服务")
@ApiPackage(code="brand-api",name="品牌管理服务",description = "后台品牌管理维护操作接口")
public class BrandProductController {

    @Autowired
    private BrandProductService brandProductService;


    @ApiOperation(code="getBrandProducts",name="查询品牌的产品列表",description = "查询品牌的产品列表")
    @AuditLog(object="getBrandProducts",operation = "查询品牌的产品列表",type = OperationEnum.query)
    @RequestMapping(path = "/list/{pageNum}/{pageSize}",method = RequestMethod.POST)
    public ResultJson<?> getBrandProducts(@RequestBody(required=false) BrandProduct brandProduct, @PathVariable(required=false,name="pageNum") int pageIndex, @PathVariable(required=false,name="pageSize") int pageSize) {
        ResultJson<?> res = brandProductService.getBrandProducts(brandProduct, pageIndex, pageSize);
        return res;
    }

    @ApiOperation(code="getBrandProductDetail",name="查询品牌的产品价格详情",description = "查询品牌的产品价格详情")
    @AuditLog(object="getBrandProductDetail",operation = "查询品牌的产品价格详情",type = OperationEnum.query)
    @RequestMapping(path = "/detail",method = RequestMethod.POST)
    public ResultJson<?> getBrandProductPriceDetail(@RequestBody(required=false) BrandProduct brandProduct) {
        ResultJson<?> res = brandProductService.getBrandProductDetail(brandProduct);
        return res;
    }

    @ApiOperation(code="saveBrandProductPriceRule",name="保存一个品牌的一种产品的价格规则",description = "保存一个品牌的一种产品的价格规则")
    @AuditLog(object="saveBrandProductPriceRule",operation = "保存一个品牌的一种产品的价格规则",type = OperationEnum.query)
    @RequestMapping(path = "/rule/save",method = RequestMethod.POST)
    public ResultJson<?> saveBrandProductPriceRule(@RequestBody(required=false) List<PriceRule> priceRuleList) {
        ResultJson<?> res = brandProductService.saveBrandProductPriceRule(priceRuleList);
        return res;
    }

    @ApiOperation(code="getBrandProductPrices",name="查询一个品牌的一种产品的商品价格列表",description = "保存一个品牌的一种产品的价格规则",type = "common")
    @AuditLog(object="getBrandProductPrices",operation = "查询一个品牌的一种产品的商品价格列表",type = OperationEnum.query)
    @RequestMapping(path = "/prices",method = RequestMethod.GET)
    public ResultJson<?> getBrandProductPrices(@RequestParam(name="brandCode") String brandCode,@RequestParam(name="productCode")String productCode) {
        List<GoodsPriceVo> res = brandProductService.queryBrandProductPrice(brandCode, productCode);
        ResultJson<List<GoodsPriceVo>> resultJson = ResultJson.success();
        resultJson.setData(res);
        return resultJson;
    }

    @ApiOperation(code="getBrandProductList",name="查询品牌产品详情",description = "查询品牌产品详情",type = "common")
    @AuditLog(object="getBrandProductList",operation = "查询品牌产品详情",type = OperationEnum.query)
    @RequestMapping(path = "/detail",method = RequestMethod.GET)
    public ResultJson<List<BrandProductGoodDetail>> getBrandProductList(@RequestParam(name="brandCode") String brandCode) {
        List<BrandProductGoodDetail> res = brandProductService.getBrandProductList(brandCode);
        ResultJson<List<BrandProductGoodDetail>> resultJson = ResultJson.success();
        resultJson.setData(res);
        return resultJson;
    }

    @ApiOperation(code="assignProductGoodforBrand",name="品牌产品分配商品",description = "品牌产品分配商品",type = "common")
    @AuditLog(object="assignProductGoodforBrand",operation = "品牌产品分配商品",type = OperationEnum.query)
    @RequestMapping(path = "/goods/assign",method = RequestMethod.POST)
    public ResultJson<?> assignProductGoodforBrand(@RequestBody BrandProductItemVO brandProductItemVO) {
        ResultJson<?> res = brandProductService.assignProductGoodforBrand(brandProductItemVO);
        return res;
    }

    @ApiOperation(code="assignSupplierforBrandProduct",name="品牌产品分配供应商",description = "品牌产品分配供应商",type = "common")
    @AuditLog(object="assignProductGoodforBrand",operation = "品牌产品分配供应商",type = OperationEnum.query)
    @RequestMapping(path = "/assignSupplier",method = RequestMethod.POST)
    public ResultJson<?> assignSupplier(@RequestBody PartnerBrand PartnerBrand) {
        ResultJson<?> res = brandProductService.assignSupplier(PartnerBrand);
        return res;
    }

    @ApiOperation(code="addBrandProduct",name="品牌新增产品",description = "品牌新增产品",type = "common")
    @AuditLog(object="assignProductGoodforBrand",operation = "品牌新增产品",type = OperationEnum.query)
    @RequestMapping(path = "/addBrandProduct",method = RequestMethod.POST)
    public ResultJson<?> addBrandProduct(@RequestBody BrandProduct brandProduct) {
        ResultJson<?> res = brandProductService.addBrandProduct(brandProduct);
        return res;
    }


}
